using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace buoi2
{   
    class Accessdata
    {
        SqlConnection con = new SqlConnection();
        public Accessdata()
        {
            con.ConnectionString = "Data Source=.;Initial Catalog=shopcd;Integrated Security=True";
        }
        public void open()
        {
            if (con.State == ConnectionState.Closed)
                con.Open();
        }
        public void close()
        {
            if (con.State == ConnectionState.Open)
                con.Close();
        }
        public DataTable get_datatable(String SQL)
        {
            SqlDataAdapter adap = new SqlDataAdapter(SQL,con);
            DataTable tb = new DataTable();
            adap.Fill(tb);
            return tb;
        }
        public DataSet get_dataset(ref DataSet ds,String SQL)//ref  dataset ds de nhac nhieu table vao data set
        {
            DataTable tb = get_datatable(SQL);
         //   DataSet ds = new DataSet();
            ds.Tables.Add(tb);
            return ds;
        }
    }
}
